package com.hns.frame.mybatis;

/**
 * mysql 方言
 * @author:Fisher
 * @email:zhuangcaijin@126.com
 * @version Revision 2.0.0
 */
public class MysqlDialect implements Dialect {

	@Override
	public boolean supportsLimit() {
		return true;
	}

	@Override
	public boolean supportsLimitOffset() {
		return true;
	}

	/**
	 * mysql翻页
	 * @param querySelect
	 * @param hasOffset
	 * @param start
	 * @param size
	 * @return 返回经过翻页加工的sql语句
	 * @see com.hns.frame.mybatis.Dialect#getLimitString(java.lang.String, boolean, int, int)
	 * @author:Fisher
	 * @email:zhuangcaijin@126.com
	 */
	@Override
	public String getLimitString(String querySelect, boolean hasOffset,
			int start, int size) {
		// hasOffset always true
		if ( start > 0 ) {
		    return querySelect + " LIMIT " + start + "," + size;
		} else {
			return querySelect + " LIMIT " + size;
		}
	}

}
